package com.zhoug.demo.player.http;



import java.util.LinkedHashMap;

/**
 * 请求参数封装
 *
 * @Author 35574
 * @Date 2020/8/5
 * @Description
 */
public class RequestParamsBuild {
    /**
     * 定义常用的参数
     */
    public static final class PARAMS {
        public static final String ID = "Id";//id
        public static final String LoginName = "LoginName";//账号,手机号
        public static final String Password = "Password";//密码
        public static final String Phone = "Phone";//手机号
        public static final String LoginMode = "UseCode";//登录模式:true:手机号登录,false:账号登录
        public static final String ValidCode = "ValidCode";//短信验证码
        public static final String ValidSerialNumber = "ValidSerialNumber";//和图形验证码关联的随机数
        public static final String SearchName = "SearchName";//搜索子弹
        public static final String StartTime = "StartTime";//开始时间
        public static final String EndTime = "EndTime";//结束时间
        public static final String FirmId = "FirmId";//常用参数 Id
        public static final String AreaId = "AreaId";//常用参数 AreaId
        public static final String AreaCode = "AreaCode";//常用参数 AreaCode
        public static final String FirmTypeCode = "FirmTypeCode";//常用参数 FirmTypeCode

        public static final String Token = "Token";//
        public static final String SystemCode = "SystemCode";//系统code
        public static final String ClientType = "clientType";//用于区别app,web/h5端,实现同一个账号可以在三端同时登录而不会被踢

    }


    private LinkedHashMap<String, Object> params;

    public RequestParamsBuild() {
        params = new LinkedHashMap<>();
    }

    /**
     * 设置参数
     *
     * @param key
     * @param value
     * @return
     */
    public RequestParamsBuild put(String key, Object value) {
        params.put(key, value);
        return this;
    }
    public RequestParamsBuild putEnumValue(String key, int value) {
        if(value != BaseConstant.ENUM_NULL_VALUE){
            params.put(key, value);
        }
        return this;
    }





    /**
     * 设置每页数目
     *
     * @param id
     * @return
     */
    public RequestParamsBuild withId(String id) {
        put(PARAMS.ID, id);
        return this;
    }
    /**
     *
     *搜索字段
     * @param
     * @return
     */
    public RequestParamsBuild withSearchName(String searchName) {
        put(PARAMS.SearchName, searchName);
        return this;
    }
    /**
     * 设置每页数目
     *
     * @param firmId
     * @return
     */
    public RequestParamsBuild withFirmId(String firmId) {
        put(PARAMS.FirmId, firmId);
        return this;
    }
    /**
     * 限制开始时间和结束时间
     *
     * @param startTime
     * @param endTime
     * @return
     */
    public RequestParamsBuild withTimes(String startTime, String endTime) {
        params.put(PARAMS.StartTime, startTime);
        params.put(PARAMS.EndTime, endTime);
        return this;
    }

    /**
     * 设置区域id
     *
     * @param areaId
     * @return
     */
    public RequestParamsBuild withAreaId(String areaId) {
        put(PARAMS.AreaId, areaId);
        return this;
    }

    /**
     * 设置区域id
     *
     * @param areaCode
     * @return
     */
    public RequestParamsBuild withAreaCode(String areaCode) {
        put(PARAMS.AreaCode, areaCode);
        return this;
    }
    /**
     * 设置企业类型编码
     *
     * @param firmTypeCode
     * @return
     */
    public RequestParamsBuild withFirmTypeCode(String firmTypeCode) {
        put(PARAMS.FirmTypeCode, firmTypeCode);
        return this;
    }
    /**
     * @return 请求参数
     */
    public LinkedHashMap<String, Object> build() {

        String token = DataManager.getToken();
        if (token != null) {
            params.put(PARAMS.Token, token);
        }
        params.put(PARAMS.SystemCode, "S001_05");
        params.put(PARAMS.ClientType, "App");
        return params;
    }



}
